package com.changgou.feign;

import com.changgou.entity.Result;
import com.changgou.pojo.Order;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

@FeignClient(name="order")
public interface OrderFeign {


    /***
     * 新增数据
     * @param order
     * @return
     */
    @PostMapping("/order")
    public Result add(@RequestBody Order order);

    /***
     * 根据ID查询数据
     * @param id
     * @return
     */
    @GetMapping("/order/{id}")
    public Result findById(@PathVariable("id") String id);

    /**
     * 根据用户名查询数据
     * @param username
     * @return
     */
    @GetMapping("/order/user/{username}")
    public Result findByUsername(@PathVariable("username") String username);


    /**
     * 根据用户名查询未付款的订单
     * @param username
     * @return
     */
    @GetMapping("/order/user/unpaid/{username}")
    public Result findUnpaid(@PathVariable("username") String username);

    /**
     * 根据orderid查询订单详情
     * @param orderId
     * @return
     */
    @GetMapping("/order/findOrderId")
    public Result findOrderId(@RequestParam("orderId") String orderId);

    /**
     * 根据id删除订单
     * @param id
     * @return
     */
    @DeleteMapping(value = "/order/{id}" )
    public Result delete(@PathVariable("id") String id);
}
